<template>
    <div class="home">
      <Header/>
      <div class="content"> 
        
        <div class="card">
          <div class="box">
            <div class="cont">
            <div class="left">当前有效用户数量</div>
            <div class="right">{{(info.data1||0)}} </div>
          </div>
          <div class="cont">
            <div class="left">当前可用资金余额</div>
            <div class="right">{{dexcs(cakes)||0}}  USDT</div>
          </div>
          <div class="cont">
            <div class="left">累计转入门票金额</div>
            <div class="right">{{dexc(info.data3)}}  USDT</div>
          </div>
          <div class="cont">
            <div class="left">累计转入获得额度</div>
            <div class="right">{{dexc(info.data4)||0}} USDT</div>
          </div>
          <div class="cont">
            <div class="left">累计转入押单金额</div>
            <div class="right">{{dexc(info.data5)||0}} USDT</div>
          </div>
          <div class="cont">
            <div class="left">累计发放静态奖励</div>
            <div class="right">{{dexc(info.data6)}}  USDT</div>
          </div>
          <div class="cont">
            <div class="left">累计发放分享奖励</div>
            <div class="right">{{dexc(info.data7)}}  USDT</div>
          </div>
          <div class="cont">
            <div class="left">累计发放团队奖励</div>
            <div class="right">{{dexc(info.data8)}}  USDT</div>
          </div>
          <div class="cont">
            <div class="left">累计发放见点奖励</div>
            <div class="right">{{dexc(info.data9)}}  USDT</div>
          </div>
          <div class="cont">
            <div class="left">累计发放沉淀金额</div>
            <div class="right">{{dexc(info.data10)}}  USDT</div>
          </div>
          <div class="cont">
            <div class="left">累计发放回购金额</div>
            <div class="right">{{dexc(info.data11)}}  USDT</div>
          </div>
          <div class="cont">
            <div class="left">累计发放托底金额</div>
            <div class="right">{{dexc(info.data12)}}  USDT</div>
          </div>
          <div class="cont">
            <div class="left">累计销毁奖励额度</div>
            <div class="right">{{dexc(info.data13)}}  USDT</div>
          </div>       
          <div class="cont">
            <div class="left">累计挖矿奖励代币</div>
            <div class="right">{{dexc(info.data14)}}  DAOFA</div>
          </div>
          <div class="cont">
            <div class="left">一星用户数量</div>
            <div class="right">{{infos.d1||0}}</div>
          </div>
          <div class="cont">
            <div class="left">二星用户数量</div>
            <div class="right">{{infos.d2||0}}</div>
          </div>
          <div class="cont">
            <div class="left">三星用户数量</div>
            <div class="right">{{infos.d3||0}}</div>
          </div>
          <div class="cont">
            <div class="left">四星用户数量</div>
            <div class="right">{{infos.d4||0}}</div>
          </div>
          <div class="cont">
            <div class="left">五星用户数量</div>
            <div class="right">{{infos.d5||0}}</div>
          </div>
          <div class="cont">
            <div class="left">六星用户数量</div>
            <div class="right">{{infos.d6||0}}</div>
          </div>
          <div class="cont">
            <div class="left">七星用户数量</div>
            <div class="right">{{infos.d7||0}}</div>
          </div>
          <div class="cont">
            <div class="left">八星用户数量</div>
            <div class="right">{{infos.d8||0}}</div>
          </div>
          <div class="cont">
            <div class="left">九星用户数量</div>
            <div class="right">{{infos.d9||0}}</div>
          </div>
          <div class="cont">
            <div class="left">十星用户数量</div>
            <div class="right">{{infos.d10||0}}</div>
          </div>
       </div>
     </div>

    </div>
    <Bottom/>
</div>
</template>
<script>
import Header from '../components/header.vue';
import Bottom from '../components/bottom.vue';
import {getTotalData,getQueryLevelCount,getWhitePool,getCake} from "@/api/Public";
import Web3 from 'web3'
export default {
  name: "myContracts",
  components: {Header,Bottom},
  data() {
    return {
        current:0,
        codeWallet: "?code=" + this.$store.getters.userWallet,
        loading:false,
        list:[],
        total:0,
        info:"",
        infos:'',
        pool:"",
        cakes:'',
        userWallet:""
    }
  },
  created(){
    this.userWallet=this.$store.getters.userWallet  
    this.getInfo()
    let baseUrl=((window.location.href).split("/#/"))[0]
    if(baseUrl.indexOf('?')){
        baseUrl= ((baseUrl).split("/?"))[0]
        this.codeWallet= baseUrl+"?code=" + this.$store.getters.userWallet   
    }else{
       this.codeWallet= baseUrl+"?code=" + this.$store.getters.userWallet
    }
   
  },
  filters: {
    yingcang(val) {
      if (val&&val!="0x0000000000000000000000000000000000000000") {
        let a = val.replace(/(\w{12})\w+(\w{12})/, "$1******$2");
        return a;
      } else {
        return "-/-";
      }
    },
  },
  methods:{
    dexcs(val){
  return val?  Math.round(val*1000000)/1000000:'0'
 },
    getmyCakes(){
      getCake().then(res=>{
        console.log(res);
        this.cakes=res
      })
    },
    toshow(e,j){
      this.$set(this.list[e],'show',!j)
    },
     getInfo() {
      let userWallet = this.$store.getters.userWallet
      if(userWallet){
        getTotalData().then(res=>{
          console.log(res);
         this.info=Object.assign({},res) 
        })
        this.getmyCakes()
        getQueryLevelCount().then(res=>{
          console.log(res);
         this.infos=Object.assign({},res) 
        })
    }
   
    },
 
  dexc(val){
 if(val){
  let  ethereum = window.ethereum
 let web3s = new Web3(ethereum);
  let amount=  web3s.utils.fromWei(val +'', 'ether'); 
  // let num =val/Math.pow(10,18)
  return val? Math.round(amount*1000000)/1000000:'0'
 }else{
  return 0
 }
 },
   
    changer(e){
        this.current=e
    },
    onCopy() {
      this.$notify({
                message: this.$i18n.t("m.复制成功"),
                type: "success",
              });
    },
    onError() {
      this.$notify(this.$i18n.t("m.复制失败"));
    },
    async toPage(val) {    
     if(this.$store.getters.userWallet){
       this.$router.push({ path: val });
      }else{
        this.shows=true
      }
    },
  }
}

</script>
<style lang="scss" scoped>
@import "../../src/assets/scss/_handle.scss";

$t-mf: "PingFang";
$t-f: "DINAlternate-Bold";

.home {
  // background:  #000000 url("../assets/img/b5.png")  no-repeat fixed;
  background: #00030c;
  // background-size:contain;
  // background-position: center bottom;
  overflow-x: hidden;
  width: 750px;
  margin: 0 auto;
  min-height: 100vh;
    .content{
        margin-top: 18px;
        .title{
      font-size: 32px;
      font-weight: bold;
      color: #ffffff;
      margin: 72px auto;
      width: 360px;
      padding: 16px 0;
      position: relative;
      background: linear-gradient(180deg, #FBDF62 0%, #b18d1f 100%);
    border-radius: 36px;
    text-shadow: 1px 2px 5px #262626;
    box-shadow: 1px 2px 5px #000000;
    }

        .card {
    background: #00000070 ;
      background-size: contain;
      background-position: bottom;
          align-items: center;
          border: 1px solid #35dcf7;
      border-radius: 0;
      min-height: 200px;
      padding: 30px 40px;
      margin: 20px 30px 20px;
      display: flex;
      justify-content: space-between;
      flex-direction: column;
      .titles{
        font-size: 28px;
          font-weight: 600;
          color: #ffffff;
          padding-bottom: 30px;
          width: 100%;
          border-bottom: 1px solid #35dcf7;
      }
      
      .box{
        width: 100%;
        .cont {
          display: flex;
          align-items: center;
          justify-content: space-between;
          .left {
            font-size: 24px;
            color: #ffffff;
            white-space: nowrap;
          }
          .right{
                cursor: pointer;
                color: #35dcf7;
                max-width: 50%;

                font-size: 26px;
                font-weight: 600;
                padding: 15px 10px;
                border-radius: 0;
          }
        }
      }
    }
}
}

  </style>
